package com.jerry.base.java8.closure;

import java.util.ArrayList;
import java.util.List;

/**
 * 柯里化使用
 *
 * @author Jerry
 * @since 2024/8/1 20:32
 */
public class ClosureUsage2 {

    interface Fa {
        Fb funA(List<Integer> list);
    }

    interface Fb {
        Fc funB(List<Integer> list);
    }

    interface Fc {
        List<Integer> funC(List<Integer> list);
    }

    static Fb step1() {
        List<Integer> list1 = List.of(1, 2, 3);
        Fa fa = a -> b -> c -> {
            List<Integer> list = new ArrayList<>();
            list.addAll(a);
            list.addAll(b);
            list.addAll(c);
            return list;
        };
        return fa.funA(list1);
    }

    static Fc step2(Fb fb) {
        List<Integer> list2 = List.of(4, 5, 6);
        return fb.funB(list2);
    }

    static List<Integer> step3(Fc fc) {
        List<Integer> list3 = List.of(7, 8, 9);
        return fc.funC(list3);
    }

    /**
     * 把三个集合的数据组合在一起，但数据不能一次得到
     *
     * @param args
     */
    public static void main(String[] args) {
        Fb fb = step1();
        Fc fc = step2(fb);
        List<Integer> list = step3(fc);
        System.out.println(list);
    }
}
